package com.yinp.proapp.module.study.date.activity;

import android.view.View;

import com.yinp.proapp.base.activity.AppBaseActivity;
import com.yinp.proapp.databinding.ActivitySelectDateBinding;
import com.yinp.proapp.module.study.date.SelectDateBean;
import com.yinp.proapp.module.study.date.SelectDateUtils;
import com.yinp.proapp.utils.StatusBarUtil;

/**
 * @Author: yinp
 * @Date: 2021/8/20
 * @Description:一些通用时间选择弹
 */
public class SelectDateActivity extends AppBaseActivity<ActivitySelectDateBinding> {
    SelectDateUtils selectDateUtils1;
    SelectDateUtils selectDateUtils2;
    SelectDateUtils selectDateUtils3;
    SelectDateUtils selectDateUtils4;
    SelectDateUtils selectDateUtils5;

    @Override
    protected void initViews() {
        setStatusBarHeight(StatusBarUtil.getStatusBarHeight(mContext));
        initClick(bd.header.headerBackImg, bd.btnOne, bd.btnTwo, bd.btnThree, bd.btnFour, bd.btnFive);
        bd.header.headerCenterTitle.setText("一些通用时间选择弹");
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        if (v == bd.header.headerBackImg) {
            finish();
        } else if (bd.btnOne == v) {
            if (selectDateUtils1 == null) {
                selectDateUtils1 = new SelectDateUtils(false);
            }
            selectDateUtils1.showDate(this, 0, new SelectDateUtils.GetDateListener() {
                @Override
                public void getDate(String year, String month, String day, String hour, String minute) {
                    bd.btnOne.setText(year + "-" + month);
                }
            });
        } else if (bd.btnTwo == v) {
            if (selectDateUtils2 == null) {
                selectDateUtils2 = new SelectDateUtils(true);
            }
            selectDateUtils2.showDate(this, 1, new SelectDateUtils.GetDateListener() {
                @Override
                public void getDate(SelectDateBean selectDateBean) {
                    bd.btnTwo.setText(selectDateBean.mYear + "-" + selectDateBean.mMonth + "-" + selectDateBean.mDay);
                }
            });

        } else if (bd.btnThree == v) {
            if (selectDateUtils3 == null) {
                selectDateUtils3 = new SelectDateUtils(false);
            }
            selectDateUtils3.showDate(this, 2, new SelectDateUtils.GetDateListener() {
                @Override
                public void getDate(SelectDateBean selectDateBean) {
                    bd.btnThree.setText(selectDateBean.mHour + ":" + selectDateBean.mMinute);
                }
            });
        } else if (bd.btnFour == v) {
            if (selectDateUtils4 == null) {
                selectDateUtils4 = new SelectDateUtils(true);
            }
            selectDateUtils4.showDate(this, 3, new SelectDateUtils.GetDateListener() {
                @Override
                public void getDate(String year, String month, String day, String hour, String minute) {
                    bd.btnFour.setText(year + "-" + month + "-" + day + " " + hour + ":" + minute);
                }
            });
        } else if (bd.btnFive == v) {
            if (selectDateUtils5 == null){
                selectDateUtils5 = new SelectDateUtils(true);
            }
            selectDateUtils5.showDate(this, 1, new SelectDateUtils.GetDateListener() {
                @Override
                public void getDate(String year, String month, String day, String hour, String minute) {
                    bd.btnFive.setText(year + "-" + month + "-" + day);
                }
            });
        }
    }

}